﻿@model ArchiveViewModel
@{
    Layout = null;
    ViewBag.Title = "拆卷";
}

<script src="/Scripts/jQuery/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jQuery/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
@{Html.EnableClientValidation();}
@using (Html.BeginForm("SplitPost", "Archive", null, FormMethod.Post, new { id = "form_volume", onsubmit = "return validateCallback(this,fileSplit);", @class = "pageForm required-validate" }))
{
    <div class="pageContent">
        <div class="tabs" currentindex="0" eventtype="click" layouth="35" id="tab_Archive">
            <div class="tabsHeader">
                <div class="tabsHeaderContent">
                    <ul>
                        <li><a href="javascript:;"><span>归档材料</span></a></li>
                    </ul>
                </div>
            </div>
            <div class="tabsContent">
                <div layouth="75" style="margin: 5px;" id="div_fileSplitList">
                    <input type="hidden" name="input_pftId" value="@(ViewBag.PftId)" />
                    <input type="hidden" name="input_flId" value="@(ViewBag.FlId)" />
                    <table class="table" width="100%" nowraptd="false" targettype="dialog">
                        <thead>
                            <tr align="center">
                                <th width="20">
                                    <input type="checkbox" group="ids" class="checkboxCtrl" title="全选">
                                </th>
                                <th width="30">序号</th>
                                <th width="120">文件编号</th>
                                <th>文件材料题名</th>
                                <th width="40">总页数</th>
                            </tr>
                        </thead>
                        <tbody>
                            @{int numb = 0;}
                            @foreach (var item in Model.TheBcdVolumedirectoryList)
                            {
                                numb++;
                                <tr target="ids" rel="@item.Vd_ID" align="center">

                                    <td>
                                        <input name="ids" value="@(item.Vd_ID)" type="checkbox">
                                    </td>
                                    <td>
                                        @(numb)
                                    </td>
                                    <td>@(item.Vd_Code)</td>
                                    <td>@(item.Vd_Name)</td>
                                    <td>@(item.Vd_PageNumb)</td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="tabs hide" currentindex="0" eventtype="click" layouth="35" id="tab_file">
            <div class="tabsHeader">
                <div class="tabsHeaderContent">
                    <ul>
                        <li><a href="javascript:;"><span>新案卷信息</span></a></li>
                    </ul>
                </div>
            </div>
            <div class="tabsContent">
                <div>
                    @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_ID, new { @type = "hidden" })
                    @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Pft_ID, new { @type = "hidden" })
                    <table class="tab01 tabNo" width="95%;">
                        <tr>
                            <td class="td1" style="width: 35%;">文件类型：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_FileType, new { @class = "input02" })
                                @Html.ValidationMessageFor(model => model.TheBcdFilelistInfo.Fl_FileType)
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">档案号：</td>
                            <td>
                                @Html.TextAreaFor(model => model.TheBcdFilelistInfo.Fl_Code, new { @class = "input05" })
                                @Html.ValidationMessageFor(model => model.TheBcdFilelistInfo.Fl_Code)
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">流水号：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_Numb, new { Value = Model.TheBcdFilelistInfo.Fl_Numb.ToString("D3"), @class = "input02 digits" })
                                @Html.ValidationMessageFor(model => model.TheBcdFilelistInfo.Fl_Numb)
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">档案馆号：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_Archive, new { @class = "input02" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">项目名称：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_Item, new { @class = "input02" })
                                @Html.ValidationMessageFor(model => model.TheBcdFilelistInfo.Fl_Item)
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">起讫里程/有关单位：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_FileTitle, new { @class = "input02" })
                                @Html.ValidationMessageFor(model => model.TheBcdFilelistInfo.Fl_FileTitle)
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">文件名称：</td>
                            <td>
                                @Html.TextAreaFor(model => model.TheBcdFilelistInfo.Fl_FileName, new { cols = "3", @class = "input05" })
                                @Html.ValidationMessageFor(model => model.TheBcdFilelistInfo.Fl_FileName)
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">立卷单位：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_Unit, new { @class = "input02" })
                                @Html.ValidationMessageFor(model => model.TheBcdFilelistInfo.Fl_Unit)
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">起止日期：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_StartDate, new { @class = "date ", @readonly = "readonly", format = "yyyy-MM", @style = "width:91px;float:left;" })<span style="float: left;">—</span>@Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_EndDate, new { @class = "date ", @readonly = "readonly", format = "yyyy-MM", @style = "width:91px;" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">件数：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_Kit, new { @class = "input02" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">总页数：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_Page, new { @class = "input02" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">保管期限：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_Kept, new { @class = "input02" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">密级：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_Level, new { @class = "input02" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">立卷人：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_FilingMan, new { @class = "input02" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">立卷时间：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_FilingTime, new { @class = "date input02", @readonly = "readonly", format = "yyyy-MM-dd" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">检查人：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_CheckMan, new { @class = "input02" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">检查时间：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_CheckTime, new { @class = "date input02", @readonly = "readonly", format = "yyyy-MM-dd" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">互见号：</td>
                            <td>
                                @Html.TextBoxFor(model => model.TheBcdFilelistInfo.Fl_TheNo, new { @class = "input02" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">说明：</td>
                            <td>
                                @Html.TextAreaFor(model => model.TheBcdFilelistInfo.Fl_Explain, new { cols = "3", @class = "input05" })
                            </td>
                        </tr>
                        <tr>
                            <td class="td1">备注：</td>
                            <td>
                                @Html.TextAreaFor(model => model.TheBcdFilelistInfo.Fl_Remark, new { cols = "3", @class = "input05" })
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="formBar">
        <ul id="bar_Archive">
            <li>
                <button type="button" onclick="splitPost(0)" class="btn btn-success btn-sm">
                    直接拆出</button>
            </li>
            <li>
                <button type="button" onclick="splitNewFile(1)" class="btn btn-success btn-sm">
                    拆出到新卷</button>
            </li>
            <li>
                <button type="button" class="close btn btn-default btn-sm">
                    取消</button>
            </li>
        </ul>
        <ul class="hide" id="bar_file">
            <li>
                <button type="button" onclick="splitNewFile(0)" class="btn btn-success btn-sm">
                    上一步</button>
            </li>
            <li>
                <button type="button" onclick="splitPost(1)" class="btn btn-success btn-sm">
                    保存新卷</button>
            </li>
            <li>
                <button type="button" class="close btn btn-default btn-sm">
                    取消</button>
            </li>
        </ul>
    </div>
}

<script type="text/javascript">
    function fileSplit(json) {
        DWZ.ajaxDone(json);
        if (json.statusCode == DWZ.statusCode.ok) {
            refre_jgzl_cllx_index(json);
            $("#jgzl_cllx_list_@(ViewBag.Type)").loadUrl('/CompletionMaterials/ProFileType/Detail', "tab_i=1&type=@(ViewBag.Type)&id=@(ViewBag.PftId)", function (message) {
                $('#jgzl_cllx_list_@(ViewBag.Type)').parent().find("[layoutH]").layoutH();
            });
            $.pdialog.closeCurrent();
        }
    }
    function splitNewFile(i) {
        if (i == 0) {
            $("#tab_Archive").removeClass("hide");
            $("#tab_file").addClass("hide");
            $("#bar_Archive").removeClass("hide");
            $("#bar_file").addClass("hide");
        } else {
            $("#tab_Archive").addClass("hide");
            $("#tab_file").removeClass("hide");
            $("#bar_Archive").addClass("hide");
            $("#bar_file").removeClass("hide");
        }
    }
    function splitPost(i) {
        var isCheck = false;
        $("#div_fileSplitList input[name='ids']:checkbox:checked").each(function () {
            isCheck = true;
        });
        if (!isCheck) {
            alertMsg.error("请先选择您要拆出的文件！");
            return;
        }
        if (i == 0) {
            $("#tab_file").html("");
            $("#form_volume").submit();
        } else {
            //判断档案号是否存在
            var code = $("#TheBcdFilelistInfo_Fl_Code").val();
            var numb = $("#TheBcdFilelistInfo_Fl_Numb").val();
            $.getJSON(
             "/CompletionMaterials/Archive/IsCodeExist?code=" + code + "&numb=" + numb,
               function (mes) {
                   if(mes==0)
                       $("#form_volume").submit();
                   else
                       alertMsg.error("档案号已存在，请更换！");
               });
        }
    }
</script>
